﻿using UnityEngine;
using System.Collections;

public class RotatePingPong : MonoBehaviour {
	public int rotateSpeed;
    private int direction = 1;
	
	// Use this for initialization
	void Start () {
		
		rotateSpeed = 50;
	
	}
	
	// Update is called once per frame
	void Update () 
    {
        //transform.rotation = Quaternion.Euler(Mathf.Sin(Time.time * rotateSpeed) * -45, 90, 270);
        if (gameObject.tag == "enemybullet")
        {
            direction = -1;
            transform.rotation = Quaternion.Euler(Random.Range(230f,320f), 90, 270);
 
        }
        else
            transform.rotation = Quaternion.Euler(direction * Mathf.PingPong(Time.time * rotateSpeed, 180.0f), 90, 270);
	}
}
